<template>
    <h2>显示页面</h2>

    项目名称:<input type="text" v-model="F_Name" id="F_Name">
    年收益:<input type="text" v-model="F_YearMon_1" id="F_YearMon_1">-
    <input type="text" v-model="F_YearMon_2" id="F_YearMon_2">
    <input type="button" @click="Show" value="查询">
    <input type="button" @click="ADel" value="批量删除">
    <table>
        <thead>
            <tr>
                <td>
                    <input type="checkbox" value="" @click="checkAll">
                </td>
                <td>项目名称</td>
                <td>年收益</td>
                <td>月收益</td>
                <td>最低金额</td>
                <td>理财人数</td>
                <td>风险等级</td>
                <td>利息编号</td>
                <td>操作</td>
            </tr>
        </thead>
        <tbody>
            <tr v-for="item in data" :key="item.F_Id">
                <td>
                    <input type="checkbox" value="" @click="checkfan(item.F_Id)">
                </td>
                <td>{{ item.F_Name }}</td>
                <td>{{ item.F_YearMon }}</td>
                <td>{{ item.F_Month }}</td>
                <td>{{ item.F_MinMon }}</td>
                <td>{{ item.F_Num }}</td>
                <td>{{ item.F_Level }}</td>
                <td>{{ item.T_Id }}</td>
                <td><input type="button" @click="Del(item.F_Id)" value="删除"></td>
            </tr>
        </tbody>
    </table>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { onMounted } from 'vue';
import axios from 'axios';

const data = ref([{
    F_Name: ref(''),
    F_YearMon: ref(''),
    F_Month: ref(''),
    F_MinMon: ref(''),
    F_Num: ref(''),
    T_Id: ref(0),
    F_Level: ref(0),

    Interest: ref('')
}])

onMounted(() => {
    Show()
})
const F_Name = ref('');
const F_YearMon_1 = ref('');
const F_YearMon_2 = ref('');

const Show = () => {
    axios.get('http://localhost:25325/api/Demo/Show', {
        params: {

            F_Name: F_Name.value,
            F_YearMon_1: F_YearMon_1.value,
            F_YearMon_2: F_YearMon_2.value


        }
    })
        .then(res => {
            data.value = res.data;

        })
        .catch(error => {
            console.log(error);
        })
}


const Del = (F_Id: number) => {
    if (confirm("确定要删除吗?")) {
        axios.get('http://localhost:25325/api/Demo/Del', {
            params: {
                F_Id: F_Id
            }
        })
            .then(res => {
                if (res.data > 0) {
                    alert("删除成功");
                    Show()
                    return;
                }
                else {
                    alert("删除失败");
                    return;
                }
            })
    }
}

</script>